<?php
namespace Home\Controller;
use Think\Controller;


class PrivilegelistController extends Controller {

//添加特权

	function addPrivilege(){
		$privilege=M("Privilegelist");
		$userid=$_POST["userid"];
		$privilegeid=$_POST["privilegeid"];

		$data["user_id"]=$userid;
		$data["privilege_id"]=$privilegeid;
        
        $result=$privilege->add($data);
        if ($result) {
		     $this->ajaxReturn(array(
		        "code"=>200,
		        "message"=>"购买成功!"
		        ),"JSON");
		 }
		 else{
		     $this->ajaxReturn(array(
		        "code"=>500,
		        "message"=>"购买失败！"
		        ),"JSON");
		 }

	}

	//查询用户特权
	function inqurePrivilege(){

        $privilege=M("Privilegelist");
		$userid=$_POST["userid"];

        $result=$privilege
          ->where("user_id='$userid'")->select();
        if ($result) {
		     $this->ajaxReturn(array(
		        "code"=>200,
		        "message"=>"查询成功!",
		        "result"=>$result
		        ),"JSON");
		 }
		 else{
		     $this->ajaxReturn(array(
		        "code"=>500,
		        "message"=>"查询失败！"
		        ),"JSON");
		 }



	}









}